points2=read_csv("byYear2.csv")
## Rows: 5933 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): State, Year, Ban Status, Origin of Challenge
## dbl (1): banCount
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
points2=points2 %>%
mutate(Year = as.factor(Year))
points2=points2 %>%
filter(!State %in% c("Alabama", "Arizona", "Connecticut", "Delaware", "Hawaii", "Louisiana", "Montana", "Nevada", "New Mexico", "District of Columbia", "Puerto Rico"))
points2=points2 %>%
arrange(desc(banCount))
pointsTopTen=points2 %>%
filter(State %in% c("Florida", "Texas", "Pennsylvania", "Tennessee", "Missouri", "Utah", "South Carolina", "Virginia", "North Carolina", "Oklahoma"))
pointsTopTen=pointsTopTen %>%
rename("statusBan" = `Ban Status`)
pointsTopTen=pointsTopTen %>%
rename(challengeOrigin=`Origin of Challenge`)
pointsTopTen=pointsTopTen %>%
mutate(statusBan = as.factor(statusBan),
challengeOrigin = as.factor(challengeOrigin))
pointsTopTen=pointsTopTen %>%
group_by(State) %>%
add_count(statusBan)
pointsTopTen=pointsTopTen %>%
rename(statusCount=n)
pointsTopTen=pointsTopTen %>%
group_by(State) %>%
add_count(challengeOrigin)
pointsTopTen=pointsTopTen %>%
rename(originCount=n)
pointsTopTen %>%
filter(State=="Oklahoma")
## # A tibble: 45 × 7
## # Groups: State [1]
## State Year statusBan challengeOrigin banCount statusCount originCount
## <chr> <fct> <fct> <fct> <dbl> <int> <int>
## 1 Oklahoma 2021-2022 Banned P… Administrator 43 19 43
## 2 Oklahoma 2021-2022 Banned P… Administrator 43 19 43
## 3 Oklahoma 2021-2022 Banned i… Administrator 43 9 43
## 4 Oklahoma 2021-2022 Banned i… Administrator 43 12 43
## 5 Oklahoma 2021-2022 Banned i… Administrator 43 12 43
## 6 Oklahoma 2021-2022 Banned i… Administrator 43 9 43
## 7 Oklahoma 2021-2022 Banned P… Administrator 43 19 43
## 8 Oklahoma 2021-2022 Banned i… Administrator 43 12 43
## 9 Oklahoma 2021-2022 Banned i… Administrator 43 12 43
## 10 Oklahoma 2021-2022 Banned P… Administrator 43 19 43
## # ℹ 35 more rows
book_plot2=ggplot(pointsTopTen, aes(x=banCount, y= reorder(State, banCount)))+
geom_point(aes(color=Year, text = paste0("State: ", State, "<br>", "Number of Bans: ", banCount)))+
geom_line()+
theme_minimal(base_size=11)+
theme(panel.grid.major.y = element_blank(), panel.grid.major.x = element_line(color="lightgray"), panel.grid.minor.x = element_blank(), plot.caption = element_text(hjust = -0.2), text=element_text(family = "Times"))+
scale_color_manual(name = "School Year", labels = c("2021-2022", "2022-2023"), values = c("#CCCCFF", "#73c6b6"))+
scale_x_continuous(breaks = c(0,250,500,750,1000,1250,1500), labels = c("0","250","500","750","1000","1250","1500"))+
labs(title = "Book bans on the rise", subtitle = "Top ten states with the most bans", y = "", x = "Number of Bans", caption = "Data from PEN America")
## Warning in geom_point(aes(color = Year, text = paste0("State: ", State, :
## Ignoring unknown aesthetics: text
ggsave("FinalBarBellBan.pdf")
## Saving 7 x 5 in image
ggplotly(book_plot2, tooltip = "text") %>%
layout(title = list(text = paste0('Book bans on the rise',
'<br>',
'<sup>',
'Top ten states with the most bans',
'</sup>')),
annotations = list(x = 1.18, y = 1.1, text = "Data from PEN America",
xref='paper', yref='paper', showarrow = F,
xanchor='right', yanchor='auto', xshift=0, yshift=0,
font = list(size = 10)))
points3=read_csv("byYear2.csv")
## Rows: 5933 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (4): State, Year, Ban Status, Origin of Challenge
## dbl (1): banCount
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
points3=points3 %>%
rename(challengeOrigin=`Origin of Challenge`)
points3=points3 %>%
rename(statusBan = `Ban Status`)
points3=points3 %>%
mutate(statusBan = as.factor(statusBan),
challengeOrigin = as.factor(challengeOrigin))
points3=points3 %>%
filter(!statusBan %in% c("No bans"))
points3 %>%
group_by(State) %>%
ggplot(aes(x=statusBan, fill = statusBan))+
geom_bar()+
theme_minimal(base_size=12)+
theme(text=element_text(family = "Times"), legend.position = "none", plot.title = element_text(hjust = -1.5))+
labs(title = "How are books banned in the United States?", x = "", y = "", caption = "Data from PEN America")+
scale_fill_discrete_qualitative("Cold")+
coord_flip()
